<?php

namespace common\models\Admin;

use Yii;

/**
 * This is the model class for table "admin".
 *
 * @property string $id
 * @property string $username
 * @property string $password
 * @property string $salt
 * @property string $created_time
 * @property string $updated_time
 * @property string $token 登陆token api使用
 * @property string $token_expire token过期时间
 * @property int $token_status 登陆token状态  1正常 2禁用
 * @property string $refresh_token
 * @property string $login_time
 * @property string $login_ip
 * @property int $status 1正常 2禁用
 * @property int $type 1区域经理 2代理商 0管理员
 */
class AdminBase extends \common\models\CommonModel\CommonModel
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'admin';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['username', 'password', 'salt'], 'required'],
            [['created_time', 'updated_time', 'token_expire', 'login_time'], 'safe'],
            [['token_status', 'login_ip', 'status', 'type'], 'integer'],
            [['username'], 'string', 'max' => 15],
            [['password', 'token', 'refresh_token'], 'string', 'max' => 32],
            [['salt'], 'string', 'max' => 20],
            [['username'], 'unique'],
            [['token'], 'unique'],
            [['refresh_token'], 'unique'],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'username' => 'Username',
            'password' => 'Password',
            'salt' => 'Salt',
            'created_time' => 'Created Time',
            'updated_time' => 'Updated Time',
            'token' => 'Token',
            'token_expire' => 'Token Expire',
            'token_status' => 'Token Status',
            'refresh_token' => 'Refresh Token',
            'login_time' => 'Login Time',
            'login_ip' => 'Login Ip',
            'status' => 'Status',
            'type' => 'Type',
        ];
    }
}
